$(function(){
    init_persion_data();
});
function init_persion_data (){
    $.post(ctx+"SalePhone/getAllCphonePersonTask",function (r) {
        var data = r.msg;
        $("#contentPersonTask").empty();
        if (data.length >0){
            $.each(data,function(index,val){
                var title = val.spBatch;
                var fenpei = val.spFenName;
                var p= "";
                var phone = val.spRecordUrl;
                var totle = val.spLastRecord;
                var num = 0;
                if (phone !=null){
                    num = phone.split(",").length
                }
                if (fenpei == "" || fenpei == null){
                    p = "<p>未分配</p><p>"+val.spCreator+"创建于"+val.spCreatetime+"</p>";
                }else{
                    p = "<p>分配给: "+fenpei+"&nbsp;&nbsp;&nbsp; 完成量:"+num+"/"+totle+"</p><p>"+val.spCreator+"创建于"+val.spCreatetime+"</p>";
                }
                var comnall ="<a href='#' onclick='selectPersionTask(this)' data='"+val.spUuid+"'><div class=\"row box-shadow m-10 height-100\">\n" +
                    "        <div class=\"col-md-8 border-right-1\">\n" +
                    "            <h4><i class=\"fa fa-commenting-o fa-fw\"></i> "+title+"</h4>\n"+p+
                    "        </div></div></a>";
                $("#contentPersonTask").append(comnall);
            });
            $("[data-toggle='tooltip']").tooltip();
        }else{
            var data =  "<p class='text-center m-t-40'>\n" +
                "            <i class=\"fa fa-check-square-o fa-4x  muted\"></i>\n" +
                "            <br/><span>所有的任务已加载完成</span>\n" +
                "            </p>";
            $("#contentPersonTask").empty().append(data);
        }
    });
}
function  selectPersionTask(btn) {
    var uuid = $(btn).attr("data");
    $("#selectUUids").val(uuid);
    $.post(ctx+"SalePhone/loadSalePersonTaskDetail",function (r) {
        $("#salePhoneContent").empty().append(r);
    });
}